home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / HMarqueeCaption 1.1 / HMarqueeCaption Demo / PP Basic Starter.cp < prev    next >
Encoding:
Text File  |  1997-06-26  |  3.8 KB  |  150 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    PP Basic Starter.cp         ©1994-1997 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a basic PowerPlant application
  6.  
  7. #include "PP Basic Starter.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17.  
  18. #include "HMarqueeCaption.h"
  19.  
  20. // put declarations for resource ids (ResIDTs) here
  21.  
  22. const ResIDT    window_Sample        = 1;    // EXAMPLE
  23.  
  24.  
  25. // ===========================================================================
  26. //        • Main Program
  27. // ===========================================================================
  28.  
  29. void main(void)
  30. {
  31.                                     // Set Debugging options
  32.     SetDebugThrow_(debugAction_Alert);
  33.     SetDebugSignal_(debugAction_Alert);
  34.  
  35.     InitializeHeap(3);                // Initialize Memory Manager
  36.                                     // Parameter is number of Master Pointer
  37.                                     //   blocks to allocate
  38.     
  39.                                     // Initialize standard Toolbox managers
  40.     UQDGlobals::InitializeToolbox(&qd);
  41.     
  42.     new LGrowZone(20000);            // Install a GrowZone function to catch
  43.                                     //    low memory situations.
  44.  
  45.     CPPStarterApp    theApp;            // replace this with your App type
  46.     theApp.Run();
  47. }
  48.  
  49.  
  50. // ---------------------------------------------------------------------------
  51. //        • CPPStarterApp             // replace this with your App type
  52. // ---------------------------------------------------------------------------
  53. //    Constructor
  54.  
  55. CPPStarterApp::CPPStarterApp()
  56. {
  57.     // Register functions to create core PowerPlant classes
  58.     
  59.     RegisterClass_(LWindow);
  60.     RegisterClass_(HMarqueeCaption);
  61. }
  62.  
  63.  
  64. // ---------------------------------------------------------------------------
  65. //        • ~CPPStarterApp            // replace this with your App type
  66. // ---------------------------------------------------------------------------
  67. //    Destructor
  68. //
  69.  
  70. CPPStarterApp::~CPPStarterApp()
  71. {
  72. }
  73.  
  74. // ---------------------------------------------------------------------------
  75. //        • StartUp
  76. // ---------------------------------------------------------------------------
  77. //    This function lets you do something when the application starts up
  78. //    without a document. For example, you could issue your own new command.
  79.  
  80. void
  81. CPPStarterApp::StartUp()
  82. {
  83.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  84. }
  85.  
  86. // ---------------------------------------------------------------------------
  87. //        • ObeyCommand
  88. // ---------------------------------------------------------------------------
  89. //    Respond to commands
  90.  
  91. Boolean
  92. CPPStarterApp::ObeyCommand(
  93.     CommandT    inCommand,
  94.     void        *ioParam)
  95. {
  96.     Boolean        cmdHandled = true;
  97.  
  98.     switch (inCommand) {
  99.     
  100.         // Deal with command messages (defined in PP_Messages.h).
  101.         // Any that you don't handle will be passed to LApplication
  102.              
  103.         case cmd_New:
  104.                                         // EXAMPLE, create a new window
  105.             LWindow        *theWindow;
  106.             theWindow = LWindow::CreateWindow(window_Sample, this);    
  107.             theWindow->Show();
  108.             break;
  109.  
  110.  
  111.  
  112.         default:
  113.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  114.             break;
  115.     }
  116.     
  117.     return cmdHandled;
  118. }
  119.  
  120. // ---------------------------------------------------------------------------
  121. //        • FindCommandStatus
  122. // ---------------------------------------------------------------------------
  123. //    This function enables menu commands.
  124. //
  125.  
  126. void
  127. CPPStarterApp::FindCommandStatus(
  128.     CommandT    inCommand,
  129.     Boolean        &outEnabled,
  130.     Boolean        &outUsesMark,
  131.     Char16        &outMark,
  132.     Str255        outName)
  133. {
  134.  
  135.     switch (inCommand) {
  136.     
  137.         // Return menu item status according to command messages.
  138.         // Any that you don't handle will be passed to LApplication
  139.  
  140.         case cmd_New:                    // EXAMPLE
  141.             outEnabled = true;            // enable the New command
  142.             break;
  143.  
  144.         default:
  145.             LApplication::FindCommandStatus(inCommand, outEnabled,
  146.                                                 outUsesMark, outMark, outName);
  147.             break;
  148.     }
  149. }
  150.